package com.example.hao.greendao.application;

import android.app.Application;
import android.support.annotation.Nullable;

import com.example.hao.greendao.utils.DBUtils;
import com.orhanobut.logger.AndroidLogAdapter;
import com.orhanobut.logger.LogcatLogStrategy;
import com.orhanobut.logger.Logger;
import com.orhanobut.logger.PrettyFormatStrategy;

public class MyApp extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        DBUtils.init(this);

        final String LOG_TAG = "HJ";//日志的 TAG 值
        final boolean LOGGABLE = true;//是否开启日志打印
        Logger.addLogAdapter(new AndroidLogAdapter(PrettyFormatStrategy.newBuilder()
                //是否显示线程信息
                .showThreadInfo(true)
                //显示方法的数量
                .methodCount(1)
                .methodOffset(0)
                .logStrategy(new LogcatLogStrategy())
                .tag(LOG_TAG)
                .build()) {
            @Override
            public boolean isLoggable(int priority, @Nullable String tag) {
                //是否开启日志打印
                return LOGGABLE;
//                return BuildConfig.DEBUG;
            }
        });
    }
}
